package at.codebase.security;

import java.io.PrintWriter;

/**
 * Provides a more secure interface for writing to a
 * HttpServletResponse. This class should be used
 * everywhere in this application. It takes care
 * of basic security vulnerabilities like XSS and
 * XSRF.
 * 
 * @author Daniel Marth <danielmarth@gmx.at>
 */
public class SecurePrintWriter {
	
	private PrintWriter writer;
	
	public void printInsecure(String str) {
		writer.print(str);
	}
	
	public void printInsecureLine(String str) {
		writer.println(str);
	}
	
	public void printSecure(String str) {
		writer.print(SecurityUtils.sanatize(str));
	}
	
	public void printSecureLine(String str) {
		writer.println(SecurityUtils.sanatize(str));
	}
	
	public void setWriter(PrintWriter w) {
		writer = w;
	}
	
	public void flushClose(){
		writer.flush();
		writer.close();
	}

}
